import java.util.StringTokenizer;
import java.util.Vector;

class P11222_39643 {

	static Scanner11222 scanner = new Scanner11222();
	
	public static void main(String[] args) {
		int cases = scanner.getInt();
		
		try {
		
		for (int k = 0; k < cases; k++) {
			System.out.println("Case #" + (k + 1) + ":");
			process();
		}
		
		} catch (Exception e) {
			while (true) {
				
			}
		}
		
	}
	
    private static void process() {
    	
    	
		
		boolean[] a = new boolean[10002];
		
		int s = scanner.getInt();
		
		for (int k = 0; k < s; k++) {
			a[scanner.getInt()] = true;
		}
		
		boolean[] b = new boolean[10002];
		
		
		s = scanner.getInt();
		
		for (int k = 0; k < s; k++) {
			b[scanner.getInt()] = true;
		}
		
		boolean[] c = new boolean[10002];
		
		
		s = scanner.getInt();
		
		for (int k = 0; k < s; k++) {
			c[scanner.getInt()] = true;
		}
	
		
		Vector solA = new Vector();
		Vector solB = new Vector();
		Vector solC = new Vector();
		
		for (int k = 0; k < 10002; k++) {
			int number = 0;
			
			if (a[k]) number++;
			if (b[k]) number++;
			if (c[k]) number++;
			
			if (number == 1) {
				
				if (a[k]) solA.addElement(new Integer(k));
				if (b[k]) solB.addElement(new Integer(k));
				if (c[k]) solC.addElement(new Integer(k));
				
			}
			
		}
		
		int max = Math.max(solA.size(), Math.max(solB.size(), solC.size()));
		
		if (solA.size() == max) {
			System.out.print("1 ");
			print(solA);
		}
		if (solB.size() == max) {
			System.out.print("2 ");
			print(solB);
		}
		if (solC.size() == max) {
			System.out.print("3 ");
			print(solC);
		}
		
		
	}

	private static void print(Vector sol) {
		StringBuffer sb = new StringBuffer();
		sb.append(sol.size());
		for (int k = 0; k < sol.size(); k++) {
			sb.append(' ');
			sb.append(sol.elementAt(k).toString());
		}
		
		System.out.println(sb.toString());
		
	}

	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }


}

class Scanner11222 {

    StringTokenizer st = null;

    int getInt() {
            if(st == null) st = new StringTokenizer(Reader11222.readLn());
            while(! st.hasMoreTokens()) st = new StringTokenizer(Reader11222.readLn());
            return Integer.parseInt(st.nextToken());
    }

}

class Reader11222 {
static String readLn() {
    String newLine = System.getProperty("line.separator");
    StringBuffer buffer = new StringBuffer();
    int car = -1;
    try {
        car = System.in.read();
        while ((car > 0) && (car != newLine.charAt(0))) {
            buffer.append((char)car);
            car = System.in.read();
        }
        if (car == newLine.charAt(0))
        System.in.skip(newLine.length() - 1);
    } catch (java.io.IOException e) { return (null);}
    if ((car < 0) && (buffer.length() == 0)) return (null);
    return (buffer.toString()).trim();
}
}
